package com.xwltz.controller;

import com.xwltz.model.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/home")
public class HomeController {

    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index(String name) {
        System.out.println("index=" + name);
        return "index";
    }

    @RequestMapping("/rest/{name}/{id}")
    public String rest(@PathVariable String name, @PathVariable String id) {
        System.out.println("index");
        System.out.println(name);
        System.out.println(id);
        return "index";
    }

    @RequestMapping("/cookie")
    public String cookie(@CookieValue("JSESSIONID") String sessionId) {
        System.out.println(sessionId);
        return "index";
    }

    @RequestMapping("/register")
    public String register() {
        return "register";
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public String save(UserInfo userInfo) {
        System.out.println(userInfo);
        return "index";
    }
}
